package karileet.meeting.profile.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import karileet.meeting.profile.ProfileConf;
import karileet.meeting.profile.model.Weekdays;

import java.util.Calendar;

public class ScheduleService extends Service {

    @Override
    public void onCreate() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        super.onStartCommand(intent, flags, startId);
        if (intent != null) {
            initiate();
        } else {
            Log.d(ProfileConf.APP, "Skiped start command, since intent was null");
        }
        return START_STICKY;
    }

    public void initiate() {
        //overload this!
    }

    protected boolean isDayEnabled() {
        Log.d(ProfileConf.APP, "Checking if day is enabled");
        ProfileConf pc = new ProfileConf(getApplicationContext());
        Weekdays weekdays = pc.getWeekdays();
        Calendar calendar = Calendar.getInstance();
        int day = calendar.get(Calendar.DAY_OF_WEEK) - 2;
        Log.d(ProfileConf.APP, "Today is the " + day + "th day of the week");
        return weekdays.isDayEnabled(day);
    }

}